package com.itqf.controller;

import com.itqf.entity.TbItem;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/20
 * @Time: 下午4:25
 */
@Controller
public class MyController {

    @RequestMapping("/findOne")
    @ResponseBody //方法的返回值转json
    public TbItem findOne(){
        TbItem tbItem = new TbItem();
        tbItem.setId(1);
        tbItem.setPrice(1000);
        tbItem.setTitle("小米手机");

        return  tbItem;

    }

    @RequestMapping("/findAll")  //Ambiguous mapping
    @ResponseBody //方法的返回值转json
    public List<TbItem> findAll(){
        List<TbItem> list = new ArrayList<>();
        for (int i = 1; i < 100; i++) {
            TbItem tbItem = new TbItem();
            tbItem.setId(i);
            tbItem.setPrice(1000+i);
            tbItem.setTitle("小米手机"+i);

            tbItem.setCreated(new Date());
            list.add(tbItem);

        }


        return  list;
    }



}
